<?php

define('GML', 'http://www.opengis.net/gml');
define('SOS', 'http://www.opengis.net/sos/1.0');
define('OWS', 'http://www.opengis.net/ows/1.1');
define('OGC', 'http://www.opengis.net/ogc');
define('OM', 'http://www.opengis.net/om/1.0');
define('XSI', 'http://www.w3.org/2001/XMLSchema-instance');
define('WPS', 'http://www.opengis.net/wps/1.0.0');


$observations = '-0.360403,51.070595,10.8,-0.391269,53.740231,10.6,-2.233658,52.380211,-572.8,-1.794913,52.390202,10.8,-1.106851,52.997341,10.3,-0.969167,50.886166,11.8,-1.68,52.049999,11.6,-1.6033,54.621964,9.6,-0.681628,53.507389,10.4,-5.013499,50.161697,10.6,-3.736467,50.271046,11.6,0.456619,50.836517,11.9,-0.862856,51.119686,13.4,-2.796513,52.713638,11.6,1.529017,52.097462,12.6,-2.265072,51.092525,13.0,-1.266711,50.86594,13.1,-1.26674,50.866169,13.2,-3.283333,50.788334,11.8,-1.907501,53.636292,9.3,-0.498,51.640221,14.2,-0.177841,52.609718,12.9,-3.327484,50.746994,12.9,-5.666667,57.900002,11.0,-0.830326,52.447472,13.6,-0.293174,52.139896,14.9,-5.377061,50.215813,14.3,-2.204529,53.698566,9.6,-3.128968,53.398338,14.5,-2.551827,51.442371,16.2,-0.100164,51.285408,13.7,-2.12,52.087002,17.6,-3.540212,50.553707,16.1,-2.258495,51.824852,11.1,-1.134444,51.578335,18.7,-4.06676,50.328751,13.3,0.174,52.126999,14.9,-2.122765,50.876705,21.7,-1.955566,53.659119,10.8,-0.08955,52.336601,14.9,-0.556591,51.669521,17.0,-0.163526,51.365173,16.8,1.206951,51.157707,14.6,-0.615921,51.687458,17.8,-0.1,52.740002,14.2,-1.150157,52.897942,14.9,0.182,51.411999,15.6,-5.052509,50.423626,12.4,-2.711216,53.750172,9.9,-1.975,52.669998,12.8,-2.788731,54.11195,11.7,-3.67627,56.2295,12.8,-3.8548,56.1483,11.4,-2.7228,53.7896,12.8,0.67,51.57,15.7,0.261625,52.401894,14.2,1.135481,51.805862,14.4,-1.246262,51.756569,16.7,0.993576,52.182774,14.2,-0.092794,51.319958,15.1,-0.1233,51.134701,16.7,0.1249,52.314709,14.8,-0.54991,51.610851,16.6,-2.258892,51.829201,18.0,0.911743,51.91243,14.9,0.1149,52.673,14.3,-0.738,52.085999,17.5,0.134528,52.227306,15.2,0.46555,50.85936,17.2,-0.523159,52.172222,15.6,-2.478147,56.828339,12.5,-1.831056,53.922813,12.3,-2.216105,51.874531,18.2,-1.710606,55.286449,13.4,-1.533108,51.192146,17.3,-2.596094,52.010147,15.8,-0.725656,51.245235,21.8,-4.066486,50.32793,12.7,-1.487446,53.43531,14.1,-3.81824,51.642399,11.6,-2.3,53.599998,11.7,-0.249309,50.836056,15.2,-4.085641,50.364376,14.2,-1.942,57.365879,13.9,-1.572,54.5298,15.7,-1.501962,53.795734,12.4,-1.239937,51.443336,16.2,-1.3477,52.7183,13.0,-2.037782,52.01582,17.4,-3.01918,58.976559,11.9,-0.783634,54.237644,12.6,-3.0156,56.457016,13.1,-0.760763,51.40572,18.5,-0.508861,51.504894,17.4,-1.84851,51.331329,15.4,-3.53804,51.623669,10.0,-0.150556,51.101387,16.7,-2.587452,59.242538,11.1,-5.474322,50.196632,13.0,-0.9,51.200001,17.1,-3.496957,50.551151,16.5,-2.632774,51.716427,16.3,-2.142445,53.255291,12.2,-2.80825,54.217819,11.6,-3.47648,50.565239,17.4,-3.908193,50.386639,15.1,-2.55989,52.596916,16.3,-0.921457,51.431335,19.2,-6.177406,58.247753,10.0,0.329527,51.623009,16.6,0.4914,51.28812,15.4,-3.541374,54.501251,10.9,-2.183889,57.471111,12.5,-3.205776,55.833012,14.5,0.995,51.344002,14.2,-2.755302,54.666386,11.8,-0.261054,51.603306,17.4,-0.141483,52.185589,15.9,-2.586484,51.477936,15.7,-0.921307,52.47797,15.5,-0.93504,51.00544,18.4,-0.45,51.266666,16.7,-2.665215,50.948051,16.6,-4.22,52.019299,12.3,-0.14845,51.361832,16.8,-0.859687,52.898151,14.4,-1.26901,51.780365,17.3,-2.413173,51.554993,13.9,-1.9814,50.760101,18.1,-1.114275,52.597469,13.4,-3.034,57.059601,11.4,-3.213844,58.923347,10.5,-3.85,56.383335,11.9,-2.622423,51.451756,14.3,-2.0693,51.948074,16.4,-2.028179,52.648895,15.7,-1.237989,52.758022,14.6,-5.098042,58.387196,9.6,-1.509494,51.419907,14.9,-4.55382,54.178261,8.9,-1.02746,53.561775,14.4,-0.77654,51.305119,16.6,-2.1169,53.367001,12.7,-0.40661,51.802311,17.3,-1.6897,53.873299,11.3,-1.69566,53.711781,11.8,0.9013,51.9025,14.4,-0.581331,54.018711,0.0,0.5315,51.413502,14.4,-0.55,52.332001,14.7,-1.110134,53.530716,14.4,-0.463357,51.522842,17.1,-3.216398,51.801701,10.8,-4.359492,53.164127,11.6,0.758915,51.313663,16.1,-1.639406,51.011616,15.3,-4.216604,53.28046,11.7,-2.6615,52.7756,14.6,0.928259,51.908142,16.0,1.175194,51.900013,13.8,1.353708,52.869194,12.7,-1.550885,54.88232,14.1,-2.5353,52.486401,15.8,0.274833,51.186668,17.6,-4.20898,55.819458,12.3,1.417408,52.020916,14.4,-0.681111,51.967499,16.1,-1.261196,50.881702,14.3,-0.417341,53.696999,12.8,0.79011,52.101761,14.8,-0.768481,51.971443,19.3,-1.564896,52.504543,14.9,-3.52026,50.384113,16.8,-3.27245,58.652271,9.9,-3.696771,51.526794,11.4,-3.317,50.728001,18.4,-1.98,50.720001,19.5,-2.485962,53.708206,10.2,-1.319218,51.822941,17.5,1.2864,52.074299,14.5,-1.869167,51.659721,16.1,-2.32432,52.06834,16.2,-2.53525,52.486469,13.4,-0.357,51.71722,16.9,-3.204417,52.57589,16.4,0.158012,52.097557,3.0,-3.307228,54.618107,10.9,-1.062765,53.055275,14.1,-0.09698,51.279999,17.3,-2.034836,49.194817,12.4,-2.897215,54.877373,12.7,0.9113,51.912498,14.4,-2.2183,51.8694,18.2,-2.0749,53.49905,11.0,-2.19856,52.064671,19.2,-1.076,53.037998,14.7,-3.37397,50.884598,15.4,-2.771473,50.91732,22.7,1.439552,51.36385,15.6,-2.30752,53.501629,12.2,-2.607021,57.101196,13.0,-3.634586,55.910831,8.3,-0.513431,50.960682,17.4,-2.580886,51.44371,13.5,-0.356369,51.299603,17.8,-4.607649,53.274887,11.1,-0.768185,51.990166,16.2,-1.403,51.318001,13.7,0.58,51.549999,15.3,-1.686944,53.705833,12.2,-0.370339,51.463558,17.3,-1.306633,51.413776,18.1,-4.878,51.725101,11.6,-6.06,54.25,12.3,-1.571174,53.145908,12.8,0.703314,51.839161,14.9,0.383969,52.193371,14.3,-1.53036,50.915321,15.5,-1.628194,53.771721,12.7,-3.722788,53.294373,12.4,-2.538185,49.450836,12.9,-0.371819,51.547295,16.2,0.949763,52.891247,12.4,-2.933693,51.351952,15.1,-3.78788,51.956219,11.0,-4.131374,52.931259,12.6,-2.102179,52.552101,18.4,-0.394014,50.808929,12.2,-1.5225,53.594723,11.6,0.2666,51.566601,16.3,-3.266,56.389999,14.4,-1.978,51.558998,14.6,-2.55731,57.158871,12.4,-3.64127,55.07243,12.3,-5.10488,55.008911,10.7,-4.14537,55.77224,11.6,-3.008709,53.783615,12.0,-0.953064,51.285435,16.1,-3.81,52.669998,11.6,-2.754057,50.938938,17.1,-0.2833,51.3899,17.9,-6.07331,54.38205,12.3,-1.528899,54.790546,14.7,0.684804,52.965691,12.4,-0.20517,51.50042,16.1,-3.069177,56.532063,10.4,-4.35226,50.810535,11.9,-1.3399,51.069698,15.9,0.63062,51.262058,15.5,-2.79,51.490002,16.3,-0.7331,50.9977,16.5,-1.33722,53.108879,12.7,-4.354454,50.810925,12.2,-1.068673,50.899746,15.0,-1.74739,50.984341,15.3,-0.21336,51.099091,16.2,-2.51661,51.097,15.8,-0.331897,51.760235,26.6,1.246,52.093498,15.9,-0.54025,51.319027,15.9,-3.4347,54.548882,11.7,-1.137003,50.795589,16.4,-0.117495,51.5783,17.0,1.085,51.299999,11.8,-0.322285,51.292778,15.3,-1.3013,50.6978,17.0,-2.35842,53.894428,11.1,-2.141,53.845001,10.2,0.130119,52.145447,16.2,-2.0888,49.189659,13.3,-1.47131,53.233425,13.2,0.717287,51.454208,15.3,-1.909577,51.082848,15.4,-4.175751,57.837566,11.9,-0.617735,51.482342,18.2,-2.5359,51.5919,14.4,0.167333,51.0452,15.1,0.515923,51.37167,15.2,-2.19782,51.431171,16.4,-0.773889,51.352219,17.3,-0.769078,51.245548,15.7,-2.8401,56.47673,13.1,-2.439139,50.54237,15.3,-0.016651,50.978317,17.9,-0.72619,51.317322,15.7,-1.27687,51.407909,16.7,-2.1684,57.335602,14.1,-3.562832,58.614635,10.1,-3.801098,50.239082,12.3,-0.310729,53.793022,13.1,-3.360049,56.033623,12.6,-2.4875,51.826599,17.7,-3.006477,53.323387,15.3,-1.57,52.784,13.2,-0.8256,51.296299,16.5,-1.332111,51.082615,18.0,-4.360542,53.164062,11.8,0.519444,51.615501,15.5,-2.424374,51.311302,15.5,-0.29865,52.034401,16.7,0.33409,51.487827,16.3,0.599442,51.557297,15.9,-1.55815,54.48241,16.3,-5.7987,54.853001,11.8,-0.1212,52.451401,14.6,-1.70285,52.192989,16.3,-2.508547,51.305717,14.5,-0.834961,52.976246,13.3,-0.882644,51.45554,22.1,-0.676671,51.416229,16.4,-1.085038,52.593319,13.9,-3.2724,53.076801,12.5,-1.96,51.508331,16.9,-4.396,55.325001,11.5,-2.5764,51.5,13.4,-2.088604,52.599739,10.4,-0.811701,51.360767,19.3,-3.585435,50.551132,15.4,-1.513624,53.542015,12.5,0.82295,51.62458,15.6,-4.912262,56.046818,10.5,-1.39017,54.980659,12.7,-1.261279,51.398811,18.3,-2.468276,53.720417,11.2,0.878885,51.312462,16.7,-0.88267,51.9482,15.9,-3.7215,51.489502,10.4,-2.159337,51.899361,17.9,-2.143192,51.754879,13.1,-0.34049,52.893578,14.4,-4.190278,51.855,12.6,0.2576,51.161098,15.5,-2.165,57.117569,15.2,-0.75184,51.766281,17.3,-1.957607,50.814339,19.0,0.778525,51.440376,14.8,-2.97572,56.457432,11.8,-2.76745,53.369759,14.6,-4.140789,51.679951,11.6,-4.216667,50.400002,13.3,-2.358584,49.442459,13.2,-3.158655,54.931385,11.8,-0.804877,51.21106,12.9,-3.792171,53.317955,12.5,-2.914292,53.167175,15.1,-2.307641,51.005131,18.7,-1.410799,53.127384,13.7,0.172927,51.046047,15.4,-4.793676,50.240494,15.0,-0.145832,50.847443,14.0,-1.247,54.6968,12.5,-2.73311,54.935692,10.8,-1.59759,54.676849,13.5,-0.342336,54.131252,12.6,-1.93316,53.442059,5.3,-3.487,50.733059,18.2,-3.15277,50.791019,14.6,-1.566667,54.616665,13.7,-2.442795,52.147434,16.3,-0.393639,50.934349,15.4,-2.944525,54.838821,11.6,-1.4678,53.031101,12.5,1.246,51.931,1.6,-0.1882,54.095402,17.8,0.762429,52.423477,13.8,-0.98877,54.552254,11.7,-3.784463,50.477165,16.9,-3.41476,50.624279,19.0,-2.273955,51.035702,18.1,-1.912522,50.748737,17.6,-7.1713,57.719601,10.1,0.687964,51.872208,15.6,-2.042492,53.067482,13.4,-2.463568,55.706261,12.5,-2.008314,50.747265,18.5,0.041027,50.783039,14.0,-2.435907,52.041664,18.6,-2.233315,50.679276,17.0,-0.173257,51.6134,17.2,-1.331234,51.168579,15.3,-4.299088,53.392235,10.4,0.572992,50.857182,16.0,0.27128,51.022511,15.2,-0.3469,54.028801,12.5,-0.136026,53.731686,13.3,0.497636,50.854534,16.3,0.94113,52.661457,12.9,0.098495,50.779896,13.0,-7.496624,56.953915,10.1,-0.487392,52.041256,15.8,-1.29025,54.588776,14.0,-1.147985,51.91341,17.1,1.75056,52.47168,13.6,-2.445346,51.296692,13.4,1.115289,51.844452,15.5,-2.587967,51.398457,13.6,-1.1261,51.332859,16.2,-2.269192,53.746986,9.7,1.374695,51.972061,15.4,-1.947438,55.44973,13.5,-2.032986,52.686893,14.2,-0.209995,50.833004,14.2,0.274873,52.411633,14.8,-0.456712,51.832859,17.5,-1.689369,53.727795,11.5,-1.204033,52.623684,12.2,0.583198,51.521095,17.4,-0.66426,51.52787,21.0,-4.137124,50.394341,15.5,-1.453457,52.435555,16.0,-1.567767,54.001556,12.7,-2.02299,50.772659,16.7,0.165497,52.663673,16.3,-4.030558,50.326714,12.9,-1.815319,53.655727,10.9,-5.01091,57.069061,19.2,0.115,51.707001,14.7,-1.9482,52.3479,15.1,-1.060237,53.989399,12.9,-2.20891,51.886871,17.2,-1.04063,51.464069,18.3,0.623796,51.168198,15.5,-0.847264,52.586269,14.4,-2.915068,51.374519,14.4,-2.349392,52.030376,16.0,-0.663065,52.173683,16.9,-3.718883,55.986965,11.9,-1.948088,51.717079,19.4,-0.169795,53.776299,13.0,-1.26362,51.242081,15.1,-1.904167,51.194721,14.6,-0.527433,51.76907,17.5,-2.512178,51.612312,15.3,-2.134137,52.450047,16.6,-3.227985,55.750774,10.5,-0.380573,52.743671,15.7,-2.178508,53.499802,11.9,0.050055,50.782322,12.4,-2.011292,50.745323,17.9,-5.272408,56.839958,10.3,-5.813333,54.645279,12.0,-0.889034,52.083199,18.1,-2.517048,52.703838,14.4,-0.029182,52.685539,14.6,0.475523,51.719677,17.9,-0.212718,51.557594,17.7,-0.1501,51.610802,17.2,-1.719532,51.14352,10.8,-2.926944,59.292221,9.6,0.418536,51.577351,14.8,-3.799553,56.013016,11.9,-2.089248,51.894821,15.6,0.720549,51.533123,17.4,-3.162947,56.213627,12.6,-0.685117,52.884529,15.7,-0.042325,51.439354,16.7,-4.421599,55.78429,10.6,-1.979771,51.710758,18.0,-2.47304,51.885815,16.7,-0.171667,51.25,15.3,0.640588,51.792088,14.8,-2.624927,51.766819,15.1,0.0159,51.890099,22.3,-1.5029,51.224098,16.3,-3.317503,56.129971,11.7,-2.510033,51.910648,15.8,-2.129824,53.638966,11.1,-0.965509,51.282318,16.9,0.05565,51.414761,-1000.0,-4.35989,53.37941,10.8,-1.396208,50.898758,16.1,-0.029464,52.053703,15.6,-4.276257,57.685616,11.6,-0.017704,52.062569,16.9,-4.100561,57.614204,10.7,-5.1,56.82,9.7,-2.7378,52.039299,18.7,-2.099215,49.195221,12.3,0.410002,51.431042,15.8,0.609264,51.362247,16.6,-2.330346,53.719028,10.6,-1.967095,53.863491,10.1,-0.228056,51.764721,18.1,-1.2706,50.720299,16.8,-0.43355,51.417065,16.8,0.469325,51.257401,16.6,1.36604,51.3293,15.1,-2.2872,53.825802,9.9,-2.251588,53.039268,12.4,1.33176,51.280285,14.7,1.099384,51.357456,15.3,1.1376,51.373253,14.4,0.691147,51.086025,15.4,-1.659815,53.704327,12.2,0.524722,51.371666,14.7,-2.770094,53.97451,12.4,0.728928,51.380077,16.4,0.533481,51.419441,16.8,-2.79256,54.044579,11.8,-2.512772,56.783901,11.2,0.48073,52.334179,16.5,0.260288,51.186382,17.1,-1.436634,51.691502,21.3,-2.71414,53.739731,12.8,-2.906055,53.553326,12.4,-2.726841,52.901138,13.9,-2.524551,53.541458,12.0,-1.439153,51.584709,16.8,-2.842809,53.602146,12.9,-2.5149,53.625599,11.3,-2.6822,53.6875,-17.8,-2.858,54.0648,12.1,-1.692435,53.904034,12.9,-2.279234,54.0816,11.2,-2.910712,53.370426,15.1,-1.14595,52.716721,14.0,-0.4368,52.896622,15.7,-1.201559,54.531002,13.9,-2.6596,53.4571,15.3,0.755739,52.937775,13.7,0.42221,52.770569,-17.8,-0.060175,51.444981,19.6,-5.914045,54.670654,12.7,-2.85166,51.431217,15.1,-2.763055,51.607521,17.9,-1.093773,54.457417,12.5,-2.981651,53.043381,14.6,1.633918,52.700298,14.2,1.2361,52.643002,12.9,1.18888,52.42981,14.4,-0.940458,52.218388,15.2,-0.052357,53.501934,14.1,-3.2098,51.987301,10.6,-1.159573,52.254642,13.4,-2.67486,50.973251,15.5,-2.92099,51.367199,17.8,-0.42,54.290001,11.1,-0.198628,50.853897,16.5,-0.986,54.4445,11.7,-3.32865,57.646969,12.2,-1.247778,52.906113,15.4,-1.199527,51.760117,19.0,-1.5781,51.588501,19.0,-1.40272,52.009331,15.1,-2.098533,52.645267,13.3,-0.522656,50.8176,17.5,-6.261209,58.501232,10.2,-2.458373,53.195969,16.0,-1.20087,50.661251,14.3,-2.3897,57.290298,13.0,-6.754446,57.454971,8.0,-0.554003,50.965034,16.9,-3.923,55.785999,11.2,-3.910877,55.793221,10.9,-4.210339,55.735615,9.8,-1.56911,53.774502,13.5,-2.724,57.036999,11.1,-2.626934,50.949345,17.7,-4.427966,57.597324,11.9,-5.196705,57.934448,9.8,-2.776111,52.677223,15.0,-2.976608,51.337475,15.2,-2.15436,52.968407,13.5,-2.315176,52.834656,13.3,-5.122418,54.844322,10.5,-0.591717,51.511841,17.2,-3.091686,51.007698,16.3,1.198883,52.091846,14.7,-0.751,51.205002,17.7,-1.402,53.381599,12.7,-3.008516,53.348373,14.1,-2.136326,52.791294,13.0,-3.715722,55.9935,12.4,1.312907,52.04414,14.2,-3.417,53.34,14.2,-0.28,51.304001,16.5,-0.614054,51.315018,16.4,1.564865,52.189564,14.3,-2.529,51.472,15.7,-0.298337,51.373192,18.0,-1.609956,52.613823,14.0,-0.77,51.239998,18.1,-2.60703,51.407162,16.3,-3.237019,51.574402,11.9,-3.292015,51.388897,12.1,-3.182091,51.457317,19.3,-3.519879,51.653324,9.8,-3.812814,51.591068,11.2,-3.5,51.400002,-49.2,-1.46659,52.416901,15.2,-3.93,51.670399,12.0,-1.612149,53.858231,9.3,-0.0858,51.058399,17.4,-0.08376,51.120415,16.1,-0.211514,51.110626,18.5,-1.372778,53.748611,13.8,-0.272467,50.827427,15.6,-1.86008,53.819401,11.7,-1.253815,53.617458,13.2,-1.760958,53.836754,11.2,-1.713633,53.714542,11.3,-1.796297,51.548218,15.8,-2.045052,51.387558,19.3,-2.215719,52.177879,17.9,-1.777725,51.095909,17.1,-2.191504,51.249439,12.9,-1.98587,52.108601,17.9,-3.095309,53.407005,14.2';

//$observations = $_POST['observations'];

$obs_array = explode(',', $observations);

$obs_string = "";
for($i = 0; $i < sizeof($obs_array); $i += 3)
{
    $obs_string .= $obs_array[$i] . ',' . $obs_array[$i +1] . ',' . $obs_array[$i + 2];
    $obs_string .= ' ';
}


$root = new SimpleXMLElement('<wps:Execute service="WPS" version="1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd"></wps:Execute>');

$root->addChild('Identifier', 'aston.jonesrm1.algorithm.SimpleInterpolateAlgorithm', OWS);
$inputs = $root->addChild('DataInputs', null, WPS);
$input = $inputs->addChild('Input', null, WPS);
$input->addChild('Identifier', 'Observations', OWS);
$data = $input->addChild('Data', null, WPS);

$lit_data = $data->addChild('LiteralData', $obs_string, WPS);
$lit_data->addAttribute('dataType','xs:string');

$resp = $root->addChild('ResponseForm', NULL, WPS);
$doc = $resp->addChild('ResponseDocument', NULL, WPS);
$out = $doc->addChild('Output', NULL, WPS);
$out->addChild('Identifier', 'MeanImageURL', OWS);


    $url = 'http://intamap.aston.ac.uk:8080/rjwps/WebProcessingService';
    $ch = curl_init();    // initialize curl handle
    curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
    curl_setopt($ch, CURLOPT_TIMEOUT, 60); // times out after 4s
    curl_setopt($ch, CURLOPT_POST, 1); // set POST method
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close',"Content-Type: text/xml"));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $root->asXML()); // add POST fields
    $result = curl_exec($ch); // run the whole process
    curl_close($ch); 
    header('Content-type: text/xml');
   // echo $root->asXML();
    echo $result;
    
    
?>
